﻿/** 
 * Copyright / Licence
 * <p>
 * You are free:
 * <li>to Share — to copy, distribute and transmit the work
 * <li>to Remix — to adapt the work
 * </p>
 * <p>
 * Under the following conditions:
 * <li>Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
 * <li>Noncommercial — You may not use this work for commercial purposes.
 * <li>Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
 * </p>
 * <p>
 * More information can be found here:
 * <br/>
 * http://creativecommons.org/licenses/by-nc-sa/3.0/
 * </p>
 * <p>
 * Please contact Manfred Weber [manfred.weber@gmail.com] if you require a commercial licence
 * </p>
 */
 package org.dschini.data.ui.maps {
	
	import org.dschini.data.*;
	import org.dschini.utils.*;
	import flash.geom.ColorTransform;
	
	public class MapData extends Data
	{
		/* functions */
		
		public function getLocationDataSortByPopulation( level:int ):Array { return locationData.slice( 0, level*5 ); }
		
		/* properties */
		
		public var _title:String;
		public function set title( title:String ):void { _title = title; }
		public function get title():String { return _title; }
		
		public var _continents:Array;
		public function set continents( continents:Array ):void { _continents = continents; }
		public function get continents():Array { return _continents; }
		
		public var _countries:Array;
		public function set countries( countries:Array ):void { _countries = countries; }
		public function get countries():Array { return _countries; }

		public var _locationData:ExtendedArray;
		public function set locationData( locationData:ExtendedArray ):void { _locationData = locationData; }
		public function get locationData():ExtendedArray { return _locationData; }
		
		/* 
		 * map visibility and transforms 
		 */
		
		public var _backgroundVisible:Boolean;
		public function get backgroundVisible():Boolean { return _backgroundVisible; }
		public function set backgroundVisible( backgroundVisible:Boolean ):void { _backgroundVisible = backgroundVisible; }
		public var _backgroundColorTransform:ColorTransform;
		public function get backgroundColorTransform():ColorTransform { return _backgroundColorTransform; }
		public function set backgroundColorTransform( backgroundColorTransform:ColorTransform ):void { _backgroundColorTransform = backgroundColorTransform; }

		/* state lines */
		public var _stateLinesVisible:Boolean;
		public function get stateLinesVisible():Boolean { return _stateLinesVisible; }
		public function set stateLinesVisible( stateLinesVisible:Boolean ):void {
			_stateLinesVisible = stateLinesVisible;
			var i:int;
			if( continents ){
				for(i=0; i<continents.length; i++){
					MapData(continents[i]).stateLinesVisible = stateLinesVisible;
				}
			}
			if( countries ){
				for(i=0; i<countries.length; i++){
					MapData(countries[i]).stateLinesVisible = stateLinesVisible;
				}
			}
		}
		public var _stateLinesColorTransform:ColorTransform;
		public function get stateLinesColorTransform():ColorTransform { return _stateLinesColorTransform; }
		public function set stateLinesColorTransform( stateLinesColorTransform:ColorTransform ):void {
			_stateLinesColorTransform = stateLinesColorTransform;
			var i:int;
			if( continents ){
				for(i=0; i<continents.length; i++){
					MapData(continents[i]).stateLinesColorTransform = stateLinesColorTransform;
				}
			}
			if( countries ){
				for(i=0; i<countries.length; i++){
					MapData(countries[i]).stateLinesColorTransform = stateLinesColorTransform;
				}
			}
		}

		/* country lines */
		public var _countryLinesVisible:Boolean;
		public function get countryLinesVisible():Boolean { return _countryLinesVisible; }
		public function set countryLinesVisible( countryLinesVisible:Boolean ):void {
			_countryLinesVisible = countryLinesVisible;
			var i:int;
			if( continents ){
				for(i=0; i<continents.length; i++){
					MapData(continents[i]).countryLinesVisible = countryLinesVisible;
				}
			}
			if( countries ){
				for(i=0; i<countries.length; i++){
					MapData(countries[i]).countryLinesVisible = countryLinesVisible;
				}
			}
		}
		public var _countryLinesColorTransform:ColorTransform;
		public function get countryLinesColorTransform():ColorTransform { return _countryLinesColorTransform; }
		public function set countryLinesColorTransform( countryLinesColorTransform:ColorTransform ):void {
			_countryLinesColorTransform = countryLinesColorTransform;
			var i:int;
			if( continents ){
				for(i=0; i<continents.length; i++){
					MapData(continents[i]).countryLinesColorTransform = countryLinesColorTransform;
				}
			}
			if( countries ){
				for(i=0; i<countries.length; i++){
					MapData(countries[i]).countryLinesColorTransform = countryLinesColorTransform;
				}
			}
		}
		
		/* shape */
		public var _shapeVisible:Boolean;
		public function get shapeVisible():Boolean { return _shapeVisible; }
		public function set shapeVisible( shapeVisible:Boolean ):void {
			_shapeVisible = shapeVisible;
			var i:int;
			if( continents ){
				for(i=0; i<continents.length; i++){
					MapData(continents[i]).shapeVisible = shapeVisible;
				}
			}
			if( countries ){
				for(i=0; i<countries.length; i++){
					MapData(countries[i]).shapeVisible = shapeVisible;
				}
			}
		}
		public var _shapeColorTransform:ColorTransform;
		public function get shapeColorTransform():ColorTransform { return _shapeColorTransform; }
		public function set shapeColorTransform( shapeColorTransform:ColorTransform ):void {
			_shapeColorTransform = shapeColorTransform;
			var i:int;
			if( continents ){
				for(i=0; i<continents.length; i++){
					MapData(continents[i]).shapeColorTransform = shapeColorTransform;
				}
			}
			if( countries ){
				for(i=0; i<countries.length; i++){
					MapData(countries[i]).shapeColorTransform = shapeColorTransform;
				}
			}
		}
	}
}
